﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Coolite.Ext.Web;
using DAL;

namespace PeisongWeb.admin
{
    public partial class firsteditpwd :adminPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

            }
        }
        [AjaxMethod]
        public string Customer_updatePwd()
        {
            string oldpwd = Library.StringLbl.EncryptMD5(this.txt_oldPassword.Text);
            int adminId = logic.sysAdmin.getById(logic.sysAdmin.AdminID).AdminId;
            string sqlpwd = logic.sysAdmin.getById(adminId).Password;
            //判断输入的旧密码与数据库的密码是否一致
            if (oldpwd == sqlpwd)
            {
                SysAdminEntity _adminEnt = new SysAdminEntity();
                _adminEnt.AdminId = adminId;
                _adminEnt.Oldpassword = oldpwd;
                _adminEnt.IP = GetClientIP();
                _adminEnt.Password = Library.StringLbl.EncryptMD5(txt_password.Text);
                logic.sysAdmin.updatePwd(_adminEnt);
                return "1";
            }
            else
            {
                //旧密码不正确
                return "0";
            }
        }
    }
}
